<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<!DOCTYPE HTML>
<html>

<head>
    <title>用户管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>
    用户管理 <span class="c-gray en">&gt;</span>
    用户列表 </nav>
<div class="pd-20">
    <div class="text-c">

        <input type="text"  placeholder="编号" style="width:120px" class="input-text"id="code">&nbsp;&nbsp;&nbsp;
        <input type="text"  placeholder=" 姓名" style="width:120px" class="input-text"id="name">&nbsp;&nbsp;&nbsp;
<span class="select-box" style="width:150px">
			<select class="select" id="departid" size="1">
            </select>
			</span>
        &nbsp;
        <button  id="doSearch" class="btn btn-success radius" ><i class="Hui-iconfont">&#xe665;</i> 搜用户
        </button>

    </div>

    <table id="searchTable" style="margin-top:5px" style="width:1480px">
        <tr style="background-color:#a6c9e2;height:42px">
            <th colspan="10" scope="col" >
                 <span class="l"><a href="javascript:;" onClick="user_edit(null,'用户添加','<%=request.getContextPath()%>/user/edit_page.do')"
                                    class="btn btn-primary radius" ><i class="Hui-iconfont">&#xe600;</i> 添加</a>

        <a href="javascript:;" onClick="delUser()" class="btn btn-danger radius" ><i class="Hui-iconfont">&#xe6e2;</i>  批量删除</a></span>

            </th>
        </tr>
        <tr>
            <th w_num="line" width="3%;"></th>
            <th w_check="true" w_index="unid" width="3%;"></th>
            <th w_index="code" w_sort="code" width="12%">编号</th>
            <th w_index="name" width="12%;">姓名</th>
            <th w_index="sex" w_render="formatSex" width="5%">性别</th>
            <th w_index="cellphone" width="15%">电话</th>
            <th w_index="departname" w_sort="departname" width="15%">部门</th>
            <th w_index="createdate" width="15%;" w_sort="createdate">入职日期</th>
            <th w_index="inoffice" w_render="formatStatus" width="10%">状态</th>
            <th w_render="operate" width="10%;">操作</th>
        </tr>
    </table>
</div>

</body>
</html>
<%@include file="../../head-ui.jsp" %>
<script type="text/javascript">
    var gridObj;

    $(function () {
        gridObj = $.fn.bsgrid.init('searchTable', {
            url: '<%=request.getContextPath()%>/back/user/list.do',
            // autoLoad: false,
            pageSizeSelect: true,
            //pagingLittleToolbar: true,
            stripeRows: true,
            pageSize: 20,
            rowHoverColor: true,
            stripeRows: true,
            displayBlankRows: false
        });

        $("#doSearch").click(function () {
            doSearch();
        })
    });
    function doSearch() {
        var searchParames = {'code': $("#code").val(), name: encodeURI($("#name").val()), departid: $("#departid").val()};
        gridObj.search(searchParames);
    }
    function formatStatus(record, rowIndex, colIndex, options) {
        return record.inoffice == 0 ? "<span class='label label-success radius'>在职</span>" : "<span class='label radius'>离职</span>";
    }
    function formatSex(record, rowIndex, colIndex, options) {
        return record.sex == '0' ? '男' : '女';
    }
    function operate(record, rowIndex, colIndex, options) {
        return "<a title='编辑' href='javascript:void(0)' " +
                "onClick=\"user_edit('" + record.unid + "','用户编辑'," +
                "'<%=request.getContextPath()%>/user/edit_page.do')\" class='ml-5' style='text-decoration:none'><i class='Hui-iconfont'>&#xe6df;</i></a>" +

                "<a title='删除' href='javascript:void(0)' " +
                "onClick=\"user_del('" + record.unid + "')\" class='ml-5' style='text-decoration:none'><i class='Hui-iconfont'>&#xe6e2;</i></a>"+

                "<a title='角色关联' href='javascript:void(0)' " +
                "onClick=\"role_link('" + record.unid + "')\" class='ml-5' style='text-decoration:none'><i class='Hui-iconfont'>&#xe63c;</i></a>";
    }
    function delUser(){
        var unids = gridObj.getCheckedValues('unid');
        if(unids==null||unids==""){
            layer.msg('请选择需要删除的用户!',{icon: 1,time:1000});
        }else{
            user_del(unids.join(","));
        }
    }
    function role_link(unid){
        layer_show('用户角色关联',$("#contextPath").val()+"/back/user/rolelink_page.do?unid="+unid,'500','510');
    }


</script>
<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/util.js"></script>